﻿<%@ page 
language="java" 
import="java.util.*" 
import="com.csd.helper.IConstant"
import="com.csd.helper.Tool"
import="com.csd.helper.ProjectState"
import="com.csd.vo.UserVO"
import="com.csd.pojo.ChangeRecord"
pageEncoding="UTF-8"
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
HttpSession s = request.getSession();
UserVO uvo =  (UserVO)s.getAttribute(IConstant.userVO);
if(uvo==null || !uvo.getType().equals(IConstant.teamRole))
{
	response.sendRedirect(path);
}

List<ChangeRecord> changeList = (List<ChangeRecord>)request.getAttribute("listOfChange");

if(changeList==null)
{
	changeList = new ArrayList<ChangeRecord>();
}

String projstat = (String)request.getAttribute("projectState");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>变更</title>
<link href="<%=path %>/student/css/student_right.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path %>/student/js/check.js"></script>

<script type="text/javascript">
function cls(){
var area=document.getElementsByName('changeApply.reason')
if( area[0].value== '请详述变更理由...'){area[0].value =""; area[0].style.color = '#000000'; }
}

function hint(){
var area=document.getElementsByName('changeApply.reason')
if(area[0].value == ""){area[0].style.color = '#ACA899'; area[0].value = '请详述变更理由...'; }
}
</script>
<script type="text/javascript">
function checkReason(form){
var flag = true;
var reason = document.getElementsByName('changeApply.reason');
flag = checkForm(form);
if(reason[0].value == '请详述变更理由...'){
flag = false;
reason[0].focus();
}
return flag;
}

function hintForLength(){
var reason = document.getElementsByName('changeApply.reason');
if(reason[0].value.length >= 400){
document.getElementById('error1').innerHTML = "最多输入400字理由";
}else{
document.getElementById('error1').innerHTML = "";
}
}
</script>

</head>

<body onload="hint()">
    <div class="main">
    
        <h1>我的变更记录</h1>
        <hr />
        <h3>已提交的变更</h3>        
        <table width="100%" style="table-layout:fixed;word-wrap:break-word;" > 
          <tr> 
            <td class="table_head" width="100px">变更时间</td> 
            <td class="table_head" width="200px">变更类型</td> 
            <td class="table_head">变更理由</td> 
            <td class="table_head" width="100px">状态</td> 
            <td class="table_head" width="100px">结果</td> 
          </tr> 
          <%
          	if( changeList.size() > 0 )
          	{
          		String result = ""; 
          		
          		for(ChangeRecord i : changeList)
          		{
          			if(i.getResult().equals("-1"))
          				result = "暂无结果";
          			else
          				result = i.getResult();
           %>
          <tr> 
            <td><%=Tool.dateToString( i.getTime() ) %></td> 
            <td><%=i.getContent() %></td> 
            <td><%=i.getReason() %></td> 
            <td><%=i.getState() %></td> 
            <td><%=result %></td>
          </tr> 
          <%	}
          }else{ %>
          <tr> 
          	<td colspan="4" align="center">暂无记录</td>
          </tr> 
          <%} %>
        </table> 
        
        <% if(projstat == null || 
			  projstat.equals(ProjectState.apply) ||
			  projstat.equals(ProjectState.prophase) ||
			  projstat.equals(ProjectState.proHaveScore) ||
			  projstat.equals(ProjectState.prophaseReject) ||
			  projstat.equals(ProjectState.projectEnd) ||
			  projstat.equals(ProjectState.finishApply) ||
			  projstat.equals(ProjectState.telophasePass) ||
			  projstat.equals(ProjectState.waitReview)
			  )
		{
		%>
			<h3>变更申请暂不可用，你可能暂未申请项目，或者项目已被冻结</h3>
		<%}else{ %>
        
        <h3>提交新的变更</h3>
        <form action="changeApply.action" method="post" onsubmit="return checkReason(this);">
	        <table align="center">   
	          <tr> 
	            <td class="form_strong" width="100px">变更类型：</td> 
	            <td>	
	              <select name="changeApply.content" id="select"> 
                  <option  value="成员变更">成员变更</option> 
                  <option  value="项目换题">项目换题</option> 
                  <option  value="项目延期">项目延期</option> 
                  <option  value="项目中止">项目中止</option> 
                </select>  
	            </td> 
	          </tr> 
	          <tr> 
	            <td>变更理由：</td> 
	            <td>
	                <textarea name="changeApply.reason" 
	                id="textarea5" cols="45" rows="5" 
	                onkeydown="checkTextAreaLength(this, 0, 400);" 
	                onblur="checkNotNull(this);hint()" 
	                onfocus="cls();" onkeyup="checkNotNull(this);hintForLength();checkTextAreaLength(this, 0, 400);"></textarea>      
	            </td> 
	          </tr> 
	          <tr><td colspan="2" align="center">
	          <span id="error1" style="text-align:center; color:#FF0000;"></span>
	          </td></tr>
	          <tr> 
	            <td colspan="2" align="center">
	                <input type="submit" value="提交变更"/> 
	            </td> 
	          </tr> 
	        </table> 
        </form>
        <%}%>
    </div>
</body>
</html>
